[#assign menucode="shopSet"]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>商铺设置</title>
    <link href="/res/css/respective/safecenter/back-safe.css" rel="stylesheet">
    <style>
    #telDiv .msg-wrap.n-error{
    	top: 4px;
    }
    </style>
</head>
<body>
<div class="warp">
[#include "/front/common/front_headAzt.html"]
    <div class="backcontent">
    [#include "/front/common/front_leftAzt.html"]
        <form id="subform" >
            <input type="hidden" class="backinput"  name="id" value="${ext.id!}"  >
            <input type="hidden" class="backinput"  name="companyId" value="${ext.companyId!}"/>
        <div class="back-main">
            <div class="inner back-safe">
                <div class="title">商铺设置</div>
                <div class="safeform useMal">
                    <ul>
                        <li>
                            <label><i class="orange" style="width: auto;height: auto;">*</i>联系人：</label>
                            <div class="formfile">
                                <input type="text" class="backinput"  name="cantactName" value="${ext.cantactName!}"  >
                            </div>
                        </li>
                        <li>
                            <label><i class="orange" style="width: auto;height: auto;">*</i>性别：</label>
                            <div class="formfile fileradio">
                                <label><span class="radioModel [#if (ext.gender!"M")=="M" ]radioModelon[/#if]"><input type="radio" name="gender" value="M" [#if (ext.gender!"M")=="M" ] checked="checked"[/#if]  /></span> 男</label>
                                <label><span class="radioModel [#if (ext.gender!"M")=="F"]radioModelon[/#if] "><input type="radio" name="gender" value="F" [#if (ext.gender!"M")=="F"] checked="checked"[/#if]  /></span> 女</label>
                            </div>
                        </li>

                        <li>
                            <label><i class="orange" style="width: auto;height: auto;">*</i>手机：</label>
                            <div class="formfile" id="telDiv">
                                <input type="text" class="backinput"  name="cantactTel"  value="${ext.cantactTel!}"  />
                                <span class="checkSwitch">
                                        <input type="hidden"  value="${ext.display}" id="pubchecked"  name="display"    >
										<img src="/res/images/checkBoxRadio/noCheck.jpg" onclick="read(this)" [#if ext.display==1 ]style="display:none;" [/#if]  />
										<img class="pub" src="/res/images/checkBoxRadio/a_18.jpg" onclick="read(this)" [#if ext.display==0 ]style="display:none;" [/#if]  />
										公开
								</span>
                                <span id="cantactTelMsg" ></span>
                            </div>
                        </li>
                        <li>
                            <label>固话：</label>
                            <div class="formfile">
                                <input type="text" class="backinput"  name="phone" value="${ext.phone!}" />
                            </div>
                        </li>
                        <li>
                            <label>QQ：</label>
                            <div class="formfile">
                                <input type="text" class="backinput"   name="qq"  value="${ext.qq!}"  />
                            </div>
                        </li>
                        <li>
                            <label><i class="orange" style="width: auto;height: auto;">*</i>所在地区：</label>
                            <div class="ppSelect">
                                <select id="reg_province"  name="province"  data-val="${ext.province!}" value="${ext.province!}" >
                                    <option value="">省/直辖市</option>
                                </select>
                            </div>
                            <div class="ppSelect">
                                <select id="reg_city" name="city" data-val="${ext.city!}"  value="${ext.city!}" >
                                    <option value="">市</option>
                                </select>
                            </div>
                            <div class="ppSelect">
                                <select id="reg_district"  name="area"  data-val="${ext.area!}"  value="${ext.area!}" >
                                    <option value="">区/县</option>
                                </select>
                            </div>
                            <div class="detailAddr">
                                <input class="backinput" type="text" name="address"  value="${ext.address!}"  placeholder="详细地址"/>
                            </div>
                        </li>
                        <li>
                            <label>&nbsp;</label>
                            <div class="formfile">
                                [#if ext.id??]
                                    <a href="javascript:void(0);" onclick="ljsave(0);" class="abtn abtn-large sav">提交</a>
                                [#else ]
                                    <a href="javascript:void(0);" onclick="ljsave(1);" class="abtn abtn-large sav">立即提交</a>
                                [/#if]

                            </div>
                        </li>
                    </ul>
                    <div class="toSafe" style="display: none;">
                        <img class="state" src="/res/images/oparaStatus/aliveSuc_03.jpg" alt="">
                        <div class="intro">
                            <h4>恭喜，您的商铺已设置成功</h4>
                            <h5>您现在可以通过以下操作使用商铺</h5>
                        </div>
                        <div style="margin-top: 30px;">
                            <button id="seeShop" class="look" type="button"  attpath=""   onclick="location.href=$(this).attr('attpath');"  >查看店铺</button>
                            <button type="button" onclick="location.href='/product/chooseCate'" >发布商品</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        </form>
    </div>
    <!-- 底部菜单-->
[#include "/front/common/front_footerAzt.html"]
</div>
</body>
<script src="/res/js/common/jquery.1.9.1.min.js"></script>
<script src="/res/js/common/jquery.address.js"></script>
<script src="/res/js/safecenter/frontButton.js" type="text/javascript"></script>
<script src="/res/third/layer/layer.js" type="text/javascript"></script>
<script src="/res/third/laydate/laydate.js" type="text/javascript"></script>
<script src="/res/third/layer/layer.extends.js" type="text/javascript"></script>
<script src="/res/third/nice-validator/jquery.validator.js?local=zh-CN"></script>
<script>
    $(function () {
        $.address({province:'reg_province', city : 'reg_city', district : 'reg_district', success : function() {}})
        $("#subform").validator({
            timely:2,
            focusCleanup:true,
            stopOnError:true,
            focusInvalid:true,
            rules:{
                v_phone:function (el, param, field) {
                    var isPhone = /^([0-9]{3,4}[-_－—]?)?[0-9]{7,8}$/;
                    var value=$(el).val().trim();
                    if(isPhone.test(value)){
                        return true;
                    }else{
                        return "固话格式不正确";
                    }
                },
            },
            fields: {
                cantactName: "联系人:required; length(1~30);",
                cantactTel:{
                    rule:"手机:required;mobile;",
                    target:"#cantactTelMsg"
                },
                phone:"v_phone;",
                qq:{
                    rule:"integer(+);length(~15)",
                    msg:"请填写有效的qq号码"
                },
                area:{
                    rule:"required;",
                    msg:"请选择所在地区"
                },
                address:"详细地址:required;length(1~100)"
            }
        });

    });
    function read(o){
        if($(o).hasClass("pub")){//切换到非公开
            $("#pubchecked").val(0);
        }else{//切换到公开
            $("#pubchecked").val(1);
        }
        $(o).hide();
        $(o).siblings("img").show();
    }
    function ljsave(isFirst) {
        if ($("#subform").isValid()) {
            layer.post({
                url: "/shop/upsetting",
                data: $("#subform").serialize(),
                success: function (data) {
                    $("#seeShop").attr("attpath","/shop/"+data.obj);
                    if(isFirst==1){
                        if (data.success) {
                            layer.open({
                                area: ['420px', '300px'],
                                type: 1,
                                content: $('.toSafe')
                            })
                        }
                    }else{
                        layer.msgShort("更新成功");
                        location.reload();
                    }

                }
            })
      }
    }
</script>
</html>
